import {getValueForFilter} from "./xUtil.js";
import {findJsonByCode} from "./treeUtil.js"
import absContainer from "./absContainer.js";
import cell from './cell.js';



const tmplBase =`<div  type="filter" class="filter">
                    <div  type="filter-head">                   
                    </div>  
                   </div>`;

export default class tFilter  extends absContainer {
    $container;
    $body;
    $head;
    $footer;
    vCfg;
    vAfterFilterData;

    constructor(el){
        super(el);
        this.$root.html(tmplBase);
        this.$head = this.$root.find('[type="filter-head"]');
        this.$root.on('input','input', this.evInput.bind(this));
    }

    prepare(cfg){
        this.vCfg =cfg;
        this.vAfterFilterData = this.vCfg.data;
        //初始化的情况判断 如果空 则全部
        this.setItemCheckStatus();
        this.setAllCheckStatus();
        this.renderHead();
        this.renderBody();
        this.renderFooter();
    }

    show(cfg,$parent,$target){
        this.prepare(cfg);
        this.setPos($parent,$target);
        this.vInnerClick = true;
        $(document).on(this.vClickId,this.evOff.bind(this));
        this.$root.show();
    }


    renderHead(){
        this.$head.html(cell.renderSearch({placeholder:'搜索...'}));
    }

    evClose(e){
        this.$root.hide();
        $(document).unbind(this.vClickId);
    }

    evInput(e){
        let val = e.target.value;
        //this.filter(val);

    }

}